import { defineStore } from 'pinia'
import { ref } from 'vue'
import { userMessageService } from '@/api/user.js'
export const useUserStore = defineStore('user-token', () => {
  // 用户登录权证相关
  const token = ref('')
  const getToken = (value) => {
    token.value = value
  }
  const removeToken = () => {
    token.value = ''
  }
  // 用户个人信息相关
  const userMessage = ref({})
  const getUserMessage = async () => {
    const result = await userMessageService()
    userMessage.value = result.data
    // console.log(result.data)
  }
  const removeUserMessage = () => {
    userMessage.value = ''
  }
  return {
    token,
    getToken,
    removeToken,
    userMessage,
    getUserMessage,
    removeUserMessage
  }
},{
  persist: true
})